Skip to content

Fix #814: raise clear error for empty Hazard in ImpactCalc.impact#1290

Open
ankurmahiwal118028 wants to merge 1 commit into
CLIMADA-project:developfrom
ankurmahiwal118028:fix/814-empty-hazard-error
Open

Fix #814: raise clear error for empty Hazard in ImpactCalc.impact#1290
ankurmahiwal118028 wants to merge 1 commit into
CLIMADA-project:developfrom
ankurmahiwal118028:fix/814-empty-hazard-error

Conversation

@ankurmahiwal118028
Copy link
Copy Markdown

Closes #814. Adds an early guard in ImpactCalc.impact that raises a ValueError when the Hazard has no events, replacing the obscure np.array_split crash. Regression test added in test_impact_calc.py. CHANGELOG updated.

Computing impact with a Hazard containing zero events previously
crashed deep inside ``np.array_split`` with the obscure message
"number sections must be larger than 0". This adds an early guard
in ``ImpactCalc.impact`` that raises a ``ValueError`` with a clear
explanation when ``self.hazard.size == 0``.

Closes CLIMADA-project#814
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant